const { resolve, reject } = require('core-js/fn/promise')
const mysql = require('mysql')
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'root',
  database: 'liangcang'
})

/*
 * 功能：查询数据
 * 参数：无
 * 返回：promise 查到的数据
 */
function select () {
  return new Promise((resolve, reject) => {
    connection.connect()
    connection.query('select * from lianxi', function(error, results, fields) {
      if (error) throw error
      resolve(results)
    })
    connection.end()
  })
}
// let res = select()
export { select }
select ().then(data => {
  console.log('打印')
  console.log(data)
})
